<%-- 
    Document   : cartcnp
    Created on : Dec 25, 2011, 10:20:46 PM
    Author     : VIC
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">
<%@page import="Beans.*,java.util.Vector,Models.*"%>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    </head>
     <%
                int langid = (Integer) session.getAttribute("langid"); // ngôn ngữ hiện tại
                String dsts = "'food','hurry','sl','dvt','del','status'"; // chuỗi chứa các mã tham số của trang này.
                ThamSoHT[] mdsts = ThamSoHT_Model.DSThamSo(dsts, langid); // mảng chứa các tham số của trang này.
                String del = mdsts[0].getTenTS();
                String dvt = mdsts[1].getTenTS();
                String food = mdsts[2].getTenTS();
                String hurry = mdsts[3].getTenTS();
                String sl = mdsts[4].getTenTS();
                String status = mdsts[5].getTenTS();
    %>
    <body onload="window.scrollTo(1, 0);">
        <table>
            <thead>
                <tr>
                    <th><%=food %></th>
                    <th><%=sl %></th>
                    <th><%=dvt %></th>
                    <th><%=status %></th>
                    <th><%=hurry %></th>
                    <th><%=del %></th>
                </tr>
            </thead>
       <%
            String ban = (String) request.getAttribute("ban");
            if(request.getAttribute("cart") != null)
                {
            Vector tam = (Vector) request.getAttribute("cart");
            int n = tam.size();
            int k = 5;
            if(n > 5)
                k =4;
             int numpage =0;
                            if(n%5==0)
                            {
                                numpage = n/5;
                            }
                            else
                            {
                                numpage = n/5 +1;
                            }
             int item = (Integer) request.getAttribute("item");
                for(int i=(item - 1)*k;i<(item-1)*k+k && i<n;i++)
                        {
                    String[] monan = (String[]) tam.get(i);
        %>
                    <tr>
                        <td><%=monan[1] %></td>
                        <td><%=monan[2] %></td>
                        <td><%=monan[3] %></td>
                        <td><img src="../images/<%=monan[4] %>.png"></td>
                        <td onclick="HoiThuc('<%=monan[0] %>')"><img src="../images/run.png"></td>
                        <td onclick="XoaMA('<%=monan[0] %>')"><img src="../images/del1.png"></td>
                    </tr>
        <% } %>
        </table>
        <%
                    if(n >5)
                        {
                            int trang =1;
                            if(item >1)
                                trang = item -1;
                        %>
                        <input style="margin-left: 2%;margin-top: 2%;" type="button" onclick="Refresh(<%=trang%>);" value="<<">
                        <%
                            if(item+1 <= numpage)
                                trang = item + 1;
                            else
                                trang = item;
                        %>
                        <td><input style="margin-left: 2%;" type="button" onclick="Refresh(<%=trang%>);" value=">>">
        <% }} %>
    </body>
</html>
